﻿@using XStudio.XCRF.Data.Entities.BasicInfo
@model BasicInfo
@{
    ViewBag.Title = "添加基本信息";
    Layout = "~/Views/Shared/Master.cshtml";
}
@{Html.Telerik().Window().Name("AddBasicInfoWindow").Title("添加基本信息")
    .Buttons(buttons => buttons.Clear())
    .Content(
@<text>
@{using (Ajax.BeginForm<BasicInfoController>(c => c.BasicInfoAdd(null),
    new AjaxOptions { OnBegin = "BeforeSend", OnSuccess = "OnSuccess", OnFailure = "OnError" }))
  {
@Html.HiddenFor(model => model.ID)
@Html.HiddenFor(model => model.CRFID)
@:签署知情同意书日期:@Html.DateEditorFor(model => model.AgreeTime)<br />
@:药物编号:@Html.TextBoxFor(model => model.MedicineCode)<br />
@:性别:@Html.GenderDisplayFor(model => model.CRF.Patient.Gender)<br />
@:生日:@Html.DateDisplayFor(model => model.CRF.Patient.Birthday)<br />
@:身高:@Html.Telerik().NumericTextBoxFor(model => model.Height)<br />
@:体重:@Html.Telerik().NumericTextBoxFor(model => model.Weight)<br />
@:电话:@Html.DisplayFor(model => model.CRF.Patient.Phone)<br />
@:病例来源:@Html.SourceTypeDisplayFor(model => model.Source)<br />
if (Model.Source == (byte)SourceTypes.InPatient)
{
    @:住院号:@Html.DisplayFor(model => model.AdmissionCode)<br />
}
@:病程:@Html.Telerik().NumericTextBoxFor(model => model.Course)月<br />
<input type="submit" value="提交" />
  }
}
</text>)
    .Render();
}
@{Html.Telerik().Window().Modal(true).Visible(false)
    .Name("saving").Title("系统提示")
    .Buttons(buttons => buttons.Clear())
    .ClientEvents(window => window.OnOpen("OnSavingOpen"))
    .Content(
@<text>
正在保存，请稍后...
</text>)
    .Render();
}
@{Html.Telerik().Window().Modal(true).Visible(false)
    .Name("saveSuccess").Title("系统提示")
    .Buttons(buttons => buttons.Clear())
    .ClientEvents(window => window.OnOpen("OnSaveSuccessOpen"))
    .Content(
@<text>
保存成功！
</text>)
    .Render();
}
@{Html.Telerik().Window().Modal(true).Visible(false)
    .Name("saveError").Title("系统提示")
    .Buttons(buttons => buttons.Close())
    .ClientEvents(window => window.OnOpen("OnSaveErrorOpen").OnClose("OnSaveErrorClose"))
    .Content(
@<text>
出现错误，请重试！
</text>)
    .Render();
}
<script type="text/javascript">
    function OnSavingOpen() {
        $("#saving").data("tWindow").center();
    }
    function OnSaveSuccessOpen() {
        $("#saveSuccess").data("tWindow").center();
    }
    function OnSaveErrorOpen() {
        $("#saveError").data("tWindow").center();
    }
    function OnSaveErrorClose() {
        $("#Passcode").val("");
    }

    function BeforeSend() {
        $("#saving").data("tWindow").open();
    }
    function OnSuccess(data) {
        if (data.ID) {
            var url = "@(Url.Action<BasicInfoController>(c => c.BasicInfoEdit(Guid.Empty)))";
            url = url.replace("@Guid.Empty", data.ID);
            window.location = url;
        } else {
            OnError();
        }
    }
    function OnError() {
        $("#saveError").data("tWindow").open();
        $("#saving").data("tWindow").close();
    }
</script>